package com.ai.service.made.impl;

import com.ai.common.constant.enumP.CameraNetTimeEnum;
import com.ai.entity.CameraNetStatusRecord;
import com.ai.mapper.CameraNetStatusRecordMapper;
import com.ai.service.made.ICameraNetStatusRecordService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 摄像头网络状态记录表 服务实现类
 * </p>
 *
 * @author jiaok
 * @since 2023-10-30
 */
@Service
public class CameraNetStatusRecordServiceImpl extends ServiceImpl<CameraNetStatusRecordMapper, CameraNetStatusRecord> implements ICameraNetStatusRecordService {

    @Resource
    private CameraNetStatusRecordMapper cameraNetStatusRecordMapper;

    @Override
    public CameraNetStatusRecord getCameraNetRecord(Integer id, String cameraIp) {

        return cameraNetStatusRecordMapper.getLatestCameraNetRecord(id,cameraIp);

    }

    @Override
    public void updateUNLatest(Integer id) {

        this.update(new UpdateWrapper<CameraNetStatusRecord>().eq("id",id).set("is_latest", CameraNetTimeEnum.UN_LATEST.getType()));

    }
}
